<style type="text/css">
    .edit-note{
        padding: 20px;
        background-color: #f1f1f1;
        color: #555;
        border-radius:5px;
    }
    .save-note{
        padding: 20px;
        background-color: #f1f1f1;
        color: #555;
        border-radius:5px;
        display: none;
    }
</style>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">店铺名称:</label>
        <div class="col-xs-12 col-sm-4" style="padding-top: 7px;">
            {$row.shop_name|htmlentities}
        </div>
        <label class="control-label col-xs-12 col-sm-2">店铺地址:</label>
        <div class="col-xs-12 col-sm-4" style="padding-top: 7px;">
            {$row.address|htmlentities}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">商家号码:</label>
        <div class="col-xs-12 col-sm-4" style="padding-top: 7px;">
            {$row.phone|htmlentities}
        </div>
        <label class="control-label col-xs-12 col-sm-2">外卖平台:</label>
        <div class="col-xs-12 col-sm-4" style="padding-top: 7px;">
            {$row.shop_type_text|htmlentities}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">店铺销量:</label>
        <div class="col-xs-12 col-sm-4" style="padding-top: 7px;">
            {$row.sales_volume|htmlentities}
        </div>
        <label class="control-label col-xs-12 col-sm-2">商家评分:</label>
        <div class="col-xs-12 col-sm-4" style="padding-top: 7px;">
            {$row.score|htmlentities}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">跟进记录:</label>
        <div class="col-xs-12 col-sm-10" style="padding-top: 7px;min-height: 50px;">
            {foreach $note as $v}
            <ul style="padding-inline-start:20px;">
                <li>
                    <div style="font-weight: 700;">{$v.create_dt}</div>
                    <div class="edit-note">{$v.content}      <!-- <a href="javascript:;" data-id="{$row.id}" data-index="{$v.create_dt}" onclick="editnote(this)">编辑</a> --></div>
                    <div class="save-note"><textarea style="height: 100%;width: 100%;">{$v.content}</textarea>      <a href="javascript:;" data-id="{$row.id}" data-index="{$v.create_dt}" onclick="savenote(this)">保存</a></div>
                </li>
            </ul>
            {/foreach}
        </div>
        <label class="control-label col-xs-12 col-sm-2">联系小记:</label>
        <div class="col-xs-12 col-sm-10" style="padding-top: 7px;">
            <textarea name="row[note]" cols="80" rows="5"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">是否了解霸王餐:</label>
        <div class="col-xs-12 col-sm-8">
            <select  id="c-lj" class="form-control selectpicker" name="row[lj]">
                <option value="">请选择</option>
                <option value="1" {if $row.lj==1}selected{/if}>Y-了解</option>
                <option value="2" {if $row.lj==2}selected{/if}>N-可能了解</option>
                <option value="3" {if $row.lj==3}selected{/if}>N-不了解</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">跟进意向:</label>
        <div class="col-xs-12 col-sm-8">
            <select  id="c-gjyx" class="form-control selectpicker" name="row[gjyx]">
                <option value="">请选择</option>
                <option value="1" {if $row.gjyx==1}selected{/if}>未接通</option>
                <option value="2" {if $row.gjyx==2}selected{/if}>D-说不需要/直接挂</option>
                <option value="3" {if $row.gjyx==3}selected{/if}>C-店员</option>
                <option value="4" {if $row.gjyx==4}selected{/if}>C-运营/公司</option>
                <option value="5" {if $row.gjyx==5}selected{/if}>B-让加微信</option>
                <option value="6" {if $row.gjyx==6}selected{/if}>A-已加微信</option>
                <option value="7" {if $row.gjyx==7}selected{/if}>已放弃</option>
                <option value="8" {if $row.gjyx==8}selected{/if}>已合作</option>
            </select>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed">{:__('OK')}</button>
        </div>
    </div>
</form>

<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
    function editnote(e) {
        $(e).parent('.edit-note').hide();
        $(e).parents('li').find('.save-note').show();
    }
    function savenote(e) {
        var id = $(e).attr('data-id')
        var createdt = $(e).attr('data-index')
        var content = $(e).parents('li').find('textarea').val();
        var data = {ids:id,createdt:createdt,content:content}
        $.ajax({
            url:"/hFtNsJROTk.php/shops/shop/editNote",
            data: data,
            success:function(result){
                if (result.code==1) {
                    var html = content;
                    $(e).parent('.save-note').hide();
                    $(e).parents('li').find('.edit-note').show();
                    $(e).parents('li').find('.edit-note').html(html);
                } else {
                    alert(result.msg)
                }
            }
        })
    }
</script>
